import pymysql
import pinyin.cedict
from translate import Translator
from urllib import request
import json


def pinin(typeName):
    # 转化拼音
    typeName = '硬件主板(充电)'
    print( pinyin.get( typeName, format="strip" ) )
def language_en(typeName):
    translator = Translator( from_lang="chinese", to_lang="english" )
    translation = translator.translate( typeName )

    print( str( translation.strip() ) )

def httpAdd(typeName):
    add_path = 'http://183.62.134.116:8803/base/data/addUpdateDataDictionary'
    pinType = pinyin.get( typeName, format="strip" )
    header = {'Content-Type': 'application/json',
              'trustToken': '93978ffb50540258b76230b654fa50d58a0bf380'}
    data_json = {
        "objValue1": "",
        "objName": typeName,
        "objCode": pinType,
        "orderNum": 0,
        "objParentCode": "faultType",
        "objParentId": "8c7e9779-47b3-4717-83a9-3185c0cd4d0c"
    }
    request_request = request.Request( add_path, json.dumps( data_json ).encode( 'utf-8' ), header )
    request.urlopen( request_request )



if __name__ == '__main__':
    aa = '陈旭、周锐'
    split = aa.split( '、' )
    print(split[0])

